package com.beifu.manager.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.beifu.manager.model.AssetInTruthExample;
import com.beifu.manager.model.AssetInTruthExample.Criteria;
import com.beifu.manager.service.assetintruth.AssetInTruthService;
import com.mds.manager.utils.ResponseHelp;
import com.utils.LayuiPageUtils;
import com.utils.PageUtils;


@Controller
public class AssetInTruthController {
	
	private Logger Log = Logger.getLogger(this.getClass());
	
	
	@Autowired
	private AssetInTruthService assetInTruthService;
	
	/**
	 * 资产入库列表数据
	 * @param model
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="/assetintruth/getAssetInTruthPage",produces=MediaType.APPLICATION_JSON_VALUE+";charset=utf-8")
	public String getAssetInTruthPage(Model model,HttpServletRequest request, HttpServletResponse res){
		String page = request.getParameter("page");
		
		String query_assetid = request.getParameter("assetInId");//备品单编号
		
		
		AssetInTruthExample  assetInTruthExample = new AssetInTruthExample();
		Criteria criteria = assetInTruthExample.createCriteria();
		if(!StringUtils.isEmpty(query_assetid)){
			criteria.andAssetInIdEqualTo(Long.valueOf(query_assetid));
		}
		
		PageUtils Page = new PageUtils(page);
		Page.setQueryParames(assetInTruthExample);
		Page = assetInTruthService.getAssetInTruthPage(Page);
		
		LayuiPageUtils layuiPageUtils = new LayuiPageUtils();
		layuiPageUtils.setCode("0");
		layuiPageUtils.setMsg("");
		layuiPageUtils.setCount(Page.getCountNum());
		layuiPageUtils.setData(Page.getList());
		Log.info(ResponseHelp.responseText(layuiPageUtils));
		return ResponseHelp.responseText(layuiPageUtils);
	}
	
}
